from time import sleep
import threading
from Lib.httpserver.WebFrame import WebFrame
from Lib.httpserver.HttpServer import HTTPServer
from Lib.httpserver.settings import ADDR

def StartWebframe():
    webframe = WebFrame()
    webframe.start() #启动WebFrame服务器

def StartHttpserver():
    httpserver = HTTPServer(ADDR)
    httpserver.server_foever()

if __name__ == "__main__":
    thWebframe = threading.Thread(target=StartWebframe)
    thWebframe.setDaemon(True)
    thWebframe.start() #启动WebFrame服务器

    sleep(0.5)

    thHttpserver = threading.Thread(target=StartHttpserver)
    thHttpserver.setDaemon(True)
    thHttpserver.start() #启动服务器
    
    sleep(1)
    while True:
        try:
            s = input('>>')
        except KeyboardInterrupt:
            print("收到系统退出信号，退出服务！")
            break
        if s == "q":
            print("退出ChatBot系统服务！")
            break
